package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.BloodPigeonListBean
import com.gexiaobao.pigeon.databinding.ItemImportedPigeonBinding

/**
 * @Author      : hxw
 * @Date        : 2024/9/18 15:17
 * @Describe    :
 */
class AdapterImportedBreedingPigeon : BaseQuickAdapter<BloodPigeonListBean, DataBindBaseViewHolder>(R.layout.item_imported_pigeon) {
    override fun convert(holder: DataBindBaseViewHolder, item: BloodPigeonListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemImportedPigeonBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val sexBg = when (item.sex) {
            "雌" -> {
                R.mipmap.icon_female
            }

            "雄" -> {
                R.mipmap.icon_male
            }

            else -> {
                R.mipmap.icon_sex_unknow
            }
        }
        holder.setBackgroundResource(R.id.ivSexImportedPigeon, sexBg)
    }
}